
#ifndef __COMPILER_LITERAL_HPP__
#define __COMPILER_LITERAL_HPP__

class Literal
{
public:

  Literal( const std::string& type, int integer )
  : _type( type ),
    _asString(),
    _integer( integer )
  {}

  Literal( const std::string& type, char character )
  : _type( type ),
    _asString(),
    _character( character )
  {}

  Literal( const std::string& type, bool boolean )
  : _type( type ),
    _asString(),
    _boolean( boolean )
  {}

  const std::string& ToString()
  {
    if( _asString == "" )
    {
      std::stringstream literal;

      if( _type == "integer" ) literal << _integer;
      if( _type == "char" ) literal << _character;
      if( _type == "boolean" ) literal << _boolean;

      _asString = literal.str();
    }
    return _asString;
  }

  const std::string& GetType()
  {
    return _type;
  }

  template< typename TType >
  static std::string ToString( TType literal )
  {
    std::stringstream literalStream;

    literalStream << "#" << literal;

    return literalStream.str();
  }

private:

  std::string _type;
  std::string _asString;

  union {
    int  _integer;
    char _character;
    bool _boolean;
  };
};

#endif // __COMPILER_LITERAL_HPP__
